#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "libRNG.h"

nt batch[] = { 20000, 50000, 100000, 200000, 500000, 1000000 };
int num = 100000000;

typedef float float_t;

int main()
{
	RNGStatus rng;
	unsigned int seed = 1111;
	int i, j, n;
	RNG_ID method;
	float_t *rs_h, *rs_d;
	clock_t start, end;

	for ( method = CURAND1; method <= LCG; method = (RNG_ID)(method + 1) )
	{
		createRNG( method, &rng, seed );

		for ( i = 0; i < sizeof(batch)/sizeof(batch[0]); i++ )
		{
			n = batch[i];
			rs_h = (float_t*)malloc( sizeof(float_t)*n );
			cudaMalloc( &rs_d, sizeof(float_t)*n );

			generateUniform( &rng, rs_h, n, 0, 1 ); // warm up... 
			start = clock();
			for ( j = 0; j < num/n; j++ )
			{
				generateUniform( &rng, rs_h, n, 0, 1 );				
			}	
			end = clock();
			printf( "%.3f, ", (double)num*CLOCKS_PER_SEC/(end-start)/1000/1000/1000 );

			generateUniform_d( &rng, rs_d, n, -1, 1 ); // warm up...
			start = clock();
			for ( j = 0; j < num/n; j++ )
			{
				generateUniform_d( &rng, rs_d, n, -1, 1 );
			}	
			end = clock();
			printf( "%.3f, ", (double)num*CLOCKS_PER_SEC/(end-start)/1000/1000/1000 );

			free( rs_h );
			cudaFree( rs_d );

			fflush(stdout);
		}
		printf("\n");

		destroyRNG( &rng );
	}

	system( "pause" );
	return 0;
}